﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;

namespace pxt
{
    public class Team
    {
        // the list of players on this team
        protected List<Player> mPlayers;

        // if the whole team is dead - the round is over!
        protected bool mTeamAlive;
        protected int mTeamNumber;


        public Team(int team)
        {
            mPlayers = new List<Player>();
            mTeamAlive = false;
            mTeamNumber = team;
        }

        public void AddPlayer(Player plyr)
        {
            // set our team number
            plyr.Team = mTeamNumber;

            // add the player to the list
            mPlayers.Add(plyr);
        }

        public void Spawn(Vector2 p1, Vector2 p2)
        {
            // spawn the team!
            mTeamAlive = true;
            int count = 1;
            foreach (Player p in mPlayers)
            {
                // spawn each player
                if (count == 1)
                    p.Spawn(p1);
                else
                    p.Spawn(p2);
                count++;

            }
        }


        public bool TeamAlive
        {
            get { return mTeamAlive; }
            set { mTeamAlive = value; }
        }

        public int TeamNumber
        {
            get { return mTeamNumber; }
            set { mTeamNumber = value; }
        }

        public bool AllMembersDead
        {
            get
            {
                // Return false if you find a player on the team that is still alive
                foreach (Player player in mPlayers)
                {
                    if (player.Wizard.Alive)
                    {
                        return false;
                    }
                }
                // DEAD! THEY ARE ALL DEAD!!!
                return true;
            }
        }
    }
}
